<%@ include file="/WEB-INF/jsp/include/head.jsp" %><%@ page language="java" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@ include file="/WEB-INF/jsp/include/title.jsp" %>
    <%@ include file="/WEB-INF/jsp/include/common_css.jsp" %>
    <link rel="stylesheet" type="text/css" media="screen" href="<c:url value="/css/skin/default/default.css"/>"/>   
    <%@ include file="/WEB-INF/jsp/include/common_script.jsp" %>
    <script type="text/javascript">
    //<![CDATA[
    <%@ include file="/js/bbs/bbs.js" %>

    function attach(obj, idx) {
        var val = obj.value;
        obj.style.display = 'none';

        addItem(++idx, val);
    }

    function addItem(idx, val) {
    	var display_script = '<div id=\"pw_file_disply_items' + idx + '\">' + idx + '. ' + val + ' <font color=\"#000066\"><b onclick=\"removeItem(' + idx + ')\" style=\"cursor:pointer\">remove..<\/b><\/font><\/div>';
    	var file_script = '<span id=\"pw_file_item' + idx + '\"><input id=\"file' + idx + '\" name=\"file[' + idx + ']\" type=\"file\" size=\"30\" onchange=\"attach(this, \'' + idx + '\')\" \/><\/span>';

    	if(idx == 1)
    		$("#pw_file_disply_items" + (idx - 1)).attr("innerHTML", "");
		
    	$(display_script).insertAfter("#pw_file_disply_items" + (idx - 1));
    	$(file_script).insertAfter("#pw_file_items");
    }

    function removeItem(id) {
    	$("#pw_file_disply_items" + id).remove();
    	$("#pw_file_item" + id).remove();

    	if($(":file").length == 1) {
    		$("#pw_file_disply_items0").attr("innerHTML", '<spring:message code="bbs.attachFileDesc"/>');
    		$(":file").attr("value", "").show();
    	}
    }

    $(document).load(function () {
        var doc = document.getElementById('editor').contentWindow.document;
        doc.open();
        doc.write("<html><head><style>body{font- size:10pt;font-family:굴림; margin: 3; padding: 0;}; p{margin-top:2px;margin-bottom:2px;}; P{margin-top:0px;margin-bottom:0px;}; table {border:1 solid C6C3C6};<\/style><\/head><body><\/body><\/html>");
        doc.close();
        doc.designMode = "on";            
    });
    //]]>
    </script>
</head>
<body>
<%@ include file="/WEB-INF/jsp/include/top.jsp" %>
    <form:form id="frmBbs" method="post" action="edit.do" enctype="multipart/form-data" modelAttribute="bbs" onsubmit="progress();">
    <form:hidden path="bbsNo" id="bbsNo" />
    <form:hidden path="bbsId" id="bbsId" />
    <form:hidden path="depth" id="depth" />
    <form:hidden path="delYn" id="delYn" />
    <form:hidden path="tagCnt" id="tagCnt" />
    <input type="hidden" id="command" name="command" />
    <div id="pw_content">
    <div id="pw_bbs" style="width: ${bbsType.bbsWidth}px;">
        <div id="pw_bbs_hader">${bbsType.bbsTopContent}</div>
        <div id="pw_bbs_body">
            <div id="pw_bbs_subject">
                <img src="<c:url value="/img/skin/default/title.gif"/>" class="pw_bsc" />
                <strong>${bbsType.bbsName}</strong> 
            </div>
            <div id="pw_bbs_comment">
            <c:if test="${not empty bbsType.bbsComment}">
                ${bbsType.bbsComment}
            </c:if>
            </div>
            <div id="pw_bbs_skin">
		    <jsp:include page="./skin/default/edit.jsp" />
            </div>
        </div>
    </div>
    </div>
    </form:form>
<%@ include file="/WEB-INF/jsp/include/footer.jsp" %>    
</body>
</html>